/*
 * The improved Shape in chapter 1
 *
 * Benifits of "case" class to normal class:
 * 1. hashCode(), equals(), toString() automatically created
 * 2. companion object(with apply() & unapply() implemented) created
 * 3. all fields considered "val" by default, unless explicit "var"
 */

package helloscala.practise.chapter6

case class Point(x: Double, y: Double)

abstract class Shape {
  def draw(): Unit
}

case class Circle(center: Point, radius: Double) extends Shape {
  def draw = println("Circle.draw: " + this)
}

case class Rectangle(lowerLeft: Point, height: Double, width: Double) extends Shape {
  def draw = println("Rectangle.draw: " + this)
}

case class Triangle(point1: Point, point2: Point, point3: Point) extends Shape {
  def draw = println("Triangle.draw: " + this)
}
